package behaviorTree

import (
	"fmt"
	"strconv"
)

type NodeType int32

const (
	NodeType_None NodeType = iota
	NodeType_Sequence
	NodeType_IfElse
	NodeType_Selector
	NodeType_SelectorRandW
	NodeType_StateSelector
	NodeType_Invertor
	NodeType_SuccessNoCond
	NodeType_Counter
	NodeType_CoolDown
	NodeType_UntilFail
	NodeType_Pass
	NodeType_DataSrc
	NodeType_Action
	NodeType_ActionNoop
	NodeType_ActionSuccess
	NodeType_ActionFailure
	NodeType_ActionWait
)

func init() {
	AddNodeType(int32(NodeType_None), "None")
	AddNodeType(int32(NodeType_Sequence), "Sequence")
	AddNodeType(int32(NodeType_IfElse), "IfElse")
	AddNodeType(int32(NodeType_Selector), "Selector")
	AddNodeType(int32(NodeType_SelectorRandW), "SelectorRandW")
	AddNodeType(int32(NodeType_StateSelector), "StateSelector")
	AddNodeType(int32(NodeType_Invertor), "Invertor")
	AddNodeType(int32(NodeType_SuccessNoCond), "SuccessNoCond")
	AddNodeType(int32(NodeType_Counter), "Counter")
	AddNodeType(int32(NodeType_CoolDown), "CoolDown")
	AddNodeType(int32(NodeType_UntilFail), "UntilFail")
	AddNodeType(int32(NodeType_Pass), "Pass")
	AddNodeType(int32(NodeType_DataSrc), "DataSrc")
	AddNodeType(int32(NodeType_Action), "Action")
	AddNodeType(int32(NodeType_ActionNoop), "ActionNoop")
	AddNodeType(int32(NodeType_ActionSuccess), "ActionSuccess")
	AddNodeType(int32(NodeType_ActionFailure), "ActionFailure")
	AddNodeType(int32(NodeType_ActionWait), "ActionWait")

}

var NodeType_name = map[int32]string{}
var NodeType_value = map[string]int32{}

func AddNodeType(val int32, name string) {
	_, existed := NodeType_name[val]
	if existed {
		panic(fmt.Sprintf("NodeType val is dup, %s:%d", name, val))
	}
	NodeType_name[val] = name
	NodeType_value[name] = val
}

func (x NodeType) String() string {
	return NodeType_enumName(NodeType_name, int32(x))
}
func NodeType_enumName(m map[int32]string, v int32) string {
	s, ok := m[v]
	if ok {
		return s
	}
	return strconv.Itoa(int(v))
}
